{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# if 判断"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "None False\n",
      "0 False\n",
      "1 True\n",
      "True True\n",
      "False False\n",
      " False\n",
      "0 True\n",
      "() False\n",
      "[] False\n",
      "{} False\n"
     ]
    }
   ],
   "source": [
    "a=[None,0,1,True,False,\"\",\"0\",(),[],{}]\n",
    "for i in a:\n",
    "    if i:\n",
    "        print(i,True)\n",
    "    else:\n",
    "        print(i,False)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "int"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对象的值\n",
    "class t():\n",
    "    def __init__(self,a):\n",
    "        self.a=a\n",
    "    def cc(self):\n",
    "        return self.cc\n",
    "type(t(\"23\").cc())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 类对象"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "class t:\n",
    "    def __init__(self,a,b,c=None):\n",
    "        self.a=a\n",
    "        self.b=b\n",
    "        self._c=c\n",
    "    @property\n",
    "    def c(self):\n",
    "        return self._c\n",
    "\n",
    "    @c.setter\n",
    "    def c(self,v):\n",
    "        if v is None:\n",
    "            raise UserWarning\n",
    "        self._c=v\n",
    "T=t(\"a\",\"b\")\n",
    "print(T.c)\n",
    "\n",
    "T.c=1\n",
    "print(T.c)\n",
    "\n",
    "T.c=None\n",
    "print(T.c)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 私有属性继承"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "class t:\n",
    "    def __init__(self,a,b):\n",
    "        self.a=a\n",
    "        self.__b=b\n",
    "        self.__c=0\n",
    "    @property\n",
    "    def c(self):\n",
    "        return self.__c\n",
    "\n",
    "class tt(t):\n",
    "    def __init_(self):\n",
    "        super(tt,self).__init()\n",
    "\n",
    "newtt=tt(1,3)\n",
    "newtt.a=3\n",
    "newtt.b=9\n",
    "\n",
    "newtt.b # 可以赋值\n",
    "#newtt.c=1 # 只读不可赋值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "class t:\n",
    "    def __init__(self,a,b,c=None):\n",
    "        self.a=a\n",
    "        self.b=b\n",
    "        self._c=c\n",
    "        self.d=1\n",
    "T=t(1,2,3)\n",
    "not isinstance(T,t)\n",
    "T.d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "https://blog.csdn.net/huo_1214/article/details/79233636"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 内置基本类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{}"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 引用类型的子对象\n",
    "#dict \n",
    "dd={ \"dd\":222}\n",
    "D={ \"d\":124,\"d2\":dd}\n",
    "\n",
    "D[\"d2\"].clear()\n",
    "dd\n",
    "#== 子对象是 引用， 即改变了子同时父也变了,从父操作子也变了\n",
    "\n",
    "# 归根揭底， 就是可变类型会被修改，不可变类型会拷贝。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "string argument without an encoding",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-49-ea24748488f2>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;31m# string and bytes\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0mbytes\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"1234abcd\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: string argument without an encoding"
     ]
    }
   ],
   "source": [
    "# string and bytes\n",
    "\n",
    "\"1234abcd\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 内置函数\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#hashlib "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "X:\\share\n",
      "X:\\share\n",
      "\\source_data\\text_files\\raw_data.txt\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "\n",
    "print(os.getcwd()) # 打印当前工作目录\n",
    "os.chdir('X:/share/')\n",
    "print(os.getcwd()) # 打印当前工作目录\n",
    "from pathlib import Path, PureWindowsPath\n",
    " \n",
    "filename = Path(\"/source_data/text_files/raw_data.txt\")\n",
    " \n",
    "# 将路径转换为 Windows 格式\n",
    "path_on_windows = PureWindowsPath(filename)\n",
    "\n",
    "print(path_on_windows)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
